package com.wocharging.wxapp;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.net.InetAddress;
import java.net.UnknownHostException;

@SpringBootApplication(scanBasePackages = "com.wocharging.wxapp.config")
@EnableScheduling
public class WxAppApplication {
    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext application = SpringApplication.run(WxAppApplication.class, args);
        Environment env = application.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String profile = env.getProperty("spring.profiles.active");
        String path = env.getProperty("server.servlet.context-path");
        path = path.equals("/")?"":path;
        System.out.println("\n----------------------------------------------------------\n\t" +
                "程序启动地址信息:\n\t" +
                "程序启动环境:" + profile + "\n\t" +
                "本地: \t\thttp://localhost:" + port + path + "/\n\t" +
                "外部: \t\thttp://" + ip + ":" + port + path + "/\n\t" +
                "doc: http://" + ip + ":" + port + path + "/doc.html\n" +
                "----------------------------------------------------------");
    }
}
